﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace pcsse.management
{
    public partial class development : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Priority"] != null)
                {
                    int pri = Convert.ToInt32(Session["Priority"].ToString());
                    if (pri <= 2)
                    {
                        Response.Redirect("~/default.aspx");
                    }
                }
            }
            errLb.Text = "";
        }

        protected void filterBt_Click(object sender, EventArgs e)
        {
            string filterstring = "";
            string numberTb = ((TextBox)(filterDv.FindControl("numberTb"))).Text;
            string nameTb = ((TextBox)(filterDv.FindControl("nameTb"))).Text;
            string bfilter = "";
            string sfilter = "";
            DropDownList bfilterDdl = ((DropDownList)(filterDv.FindControl("bfilterDdl")));
            DropDownList sfilterDdl = ((DropDownList)(filterDv.FindControl("sfilterDdl")));
            if (bfilterDdl.SelectedIndex != 0)
            {
                bfilter = bfilterDdl.SelectedValue;
            }
            if (sfilterDdl.SelectedIndex != 0)
            {
                sfilter = sfilterDdl.SelectedValue;
            }
            filterstring += string.Format("[{0}] LIKE '%{1}%'", pGv.Columns[1].SortExpression, numberTb);
            filterstring += string.Format(" AND [{0}] LIKE '%{1}%'", pGv.Columns[2].SortExpression, nameTb);
            filterstring += string.Format(" AND [{0}] LIKE '%{1}%'", pGv.Columns[3].SortExpression, bfilter);
            filterstring += string.Format(" AND [{0}] LIKE '%{1}%'", pGv.Columns[4].SortExpression, sfilter);
            pGvOds.FilterExpression = filterstring;
        }

        protected void pGv_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            if (e.Exception != null)
            {
                errLb.Text = "参数错误，请检查";
                e.ExceptionHandled = true;
                e.KeepInEditMode = true;
            }
        }
    }
}
